﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace BasicClasses
{
    public class EnderecoDataSource
    {
        private static EnderecoContext context = new EnderecoContext();
        private static string tableName = RoleEnvironment.GetConfigurationSettingValue("EnderecoTable");

        public static IEnumerable<Endereco> SelectAll()
        {
            return context.Enderecos;
        }

        public static void Add(Endereco endereco)
        {
            endereco.PartitionKey = endereco.Pais;
            endereco.RowKey = Guid.NewGuid().ToString();
            context.AddObject(tableName, endereco);
            context.SaveChanges();
        }
    }
}
